home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / admin-v1.000 / admin-v1 / usrdsksp < prev   
Text File  |  1995-05-20  |  862b  |  42 lines

  1. #!/bin/sh
  2. #
  3. # check for users with specified amount of disk space used
  4. #
  5. MINUID=500        # where your uids start
  6.             # (lowest "regular user")
  7. MAXBYTE=4096        # max number of 1024 byte blocks for trigger
  8.             # (1024 * (Megabytes) = MAXSIZE)
  9. #
  10. PASSWD="cat /etc/passwd"
  11.  
  12. HOST=`hostname`
  13. TMP=/tmp/duck.$$
  14. rm -f $TMP
  15.  
  16. DFCOMMAND=/bin/df        
  17.  
  18. touch $TMP
  19. for i in `$PASSWD | awk -F: '{if ($3 > '$MINUID') print $6}'`
  20. do
  21.    cd $i
  22.    x=`$DFCOMMAND . | grep "^/"`
  23.    if [ "$x" != "" ]; then    # if local to this host
  24.       size=`du -s . | awk '{print $1}'`
  25.       if [ $size -gt $MAXBYTE ]; then
  26.          echo "$i ($size)" >>$TMP
  27.       fi
  28.    fi
  29. done
  30.  
  31. n=`wc -l $TMP | awk '{print $1}'`
  32. if [ $n -gt 0 ]; then
  33.    echo " "
  34.    echo "User directories on $HOST larger than $MAXBYTE 1024-byte blocks:"
  35.    echo " "
  36.    sed 's/^/     /' $TMP
  37.    echo " "
  38. fi
  39. /bin/cp $TMP /tmp/user.chk
  40. rm -f $TMP
  41.  
  42.